package com.yhp.web;

import com.yhp.utils.RedisOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedisOperator redisOperator;//自定义工具类


    @GetMapping("/get")
    public  Object get(String key){
        Object o = redisTemplate.opsForValue().get(key);
        return o;
    }

    @GetMapping("/set")
    public  Object set(String key,String value){
       // redisTemplate.opsForValue().set(key,value);
        redisOperator.set(key,value);
        return "ok";
    }

    @GetMapping("/del")
    public  Object del(String key){
        redisTemplate.delete(key);
        return "ok";
    }

}



